package cubelabs.nexus.dao;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import cubelabs.nexus.entity.CounsellingEvent;
import cubelabs.nexus.entity.CounsellingEventStatus;

@Repository("counsellingEventDAO")
public class CounsellingEventDAO extends BaseDAO<CounsellingEvent, Long>{

	public List<CounsellingEvent> findByCounsellingAcceptorId(Long userId){
		/*CounsellingAcceptor counsellingAcceptor = new CounsellingAcceptor();
		User user = new User();
		user.setId(userId);
		counsellingAcceptor.setUser(user);*/
		List<CounsellingEvent> counsellingEvents = findByCriteria(Restrictions.eq("frmUser.id", userId));
		return counsellingEvents;
	}
	
	public List<CounsellingEvent> findByToUser(Long userId){
		/*CounsellingAcceptor counsellingAcceptor = new CounsellingAcceptor();
		User user = new User();
		user.setId(userId);
		counsellingAcceptor.setUser(user);*/
		List<CounsellingEvent> counsellingEvents = findByCriteria(
				Restrictions.and(Restrictions.or(Restrictions.eq("frmUser.id", userId),Restrictions.eq("toUser.id", userId)),
						Restrictions.eq("counsellingEventStatus",CounsellingEventStatus.Active)));
		return counsellingEvents;
	}
}
